/*
 *  Copyright (C) <2009>  Pavel Vakeš <pavel.vakes@gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <certificate_details_dialog.h>


CertificateDetailsDialog::CertificateDetailsDialog(const QSslCertificate &certificate) : QDialog()
{
	setupUi(this);

	this->txtSubO->setText(certificate.subjectInfo(QSslCertificate::Organization));
	this->txtSubO->home(false);
	this->txtSubCN->setText(certificate.subjectInfo(QSslCertificate::CommonName));
	this->txtSubCN->home(false);
	this->txtSubL->setText(certificate.subjectInfo(QSslCertificate::LocalityName));
	this->txtSubL->home(false);
	this->txtSubOU->setText(certificate.subjectInfo(QSslCertificate::OrganizationalUnitName));
	this->txtSubOU->home(false);
	this->txtSubC->setText(certificate.subjectInfo(QSslCertificate::CountryName));
	this->txtSubC->home(false);
	this->txtSubST->setText(certificate.subjectInfo(QSslCertificate::StateOrProvinceName));
	this->txtSubST->home(false);

	this->txtIsO->setText(certificate.issuerInfo(QSslCertificate::Organization));
	this->txtIsO->home(false);
	this->txtIsCN->setText(certificate.issuerInfo(QSslCertificate::CommonName));
	this->txtIsCN->home(false);
	this->txtIsL->setText(certificate.issuerInfo(QSslCertificate::LocalityName));
	this->txtIsL->home(false);
	this->txtIsOU->setText(certificate.issuerInfo(QSslCertificate::OrganizationalUnitName));
	this->txtIsOU->home(false);
	this->txtIsC->setText(certificate.issuerInfo(QSslCertificate::CountryName));
	this->txtIsC->home(false);
	this->txtIsST->setText(certificate.issuerInfo(QSslCertificate::StateOrProvinceName));
	this->txtIsST->home(false);

	this->dateValid->setDate(certificate.effectiveDate().date());
	this->dateValid->setTime(certificate.effectiveDate().time());
	this->dateExpire->setDate(certificate.expiryDate().date());
	this->dateExpire->setTime(certificate.expiryDate().time());
	this->txtSN->setText(certificate.serialNumber().toHex());
	this->txtSN->home(false);
	this->txtMD5->setText(certificate.digest(QCryptographicHash::Md5).toHex());
	this->txtMD5->home(false);
	this->txtSHA1->setText(certificate.digest(QCryptographicHash::Sha1).toHex());
	this->txtSHA1->home(false);
}

CertificateDetailsDialog::~CertificateDetailsDialog()
{
}
